package org.aplikator.client.descriptor;

import org.aplikator.client.widgets.CheckBoxWidget;
import org.aplikator.client.widgets.FormWidget;

import com.google.gwt.user.client.ui.Widget;

@SuppressWarnings("serial")
public class CheckBoxDTO implements WidgetDTO {

    private PropertyDTO<Boolean> property;

    private boolean labelAbove = false;

    @SuppressWarnings("unused")
    private CheckBoxDTO() {
    }

    public CheckBoxDTO(PropertyDTO<Boolean> property) {
        this.property = property;
    }

    public Widget getWidget(FormWidget form) {
        CheckBoxWidget field = new CheckBoxWidget(property.getLocalizedName(), property, labelAbove);
        if (property.getRefferedThrough() != null) {
            field.setEnabled(false);
        }
        form.registerDataField(field);
        return field;
    }

    public boolean isLabelAbove() {
        return labelAbove;
    }

    public void setLabelAbove(boolean labelAbove) {
        this.labelAbove = labelAbove;
    }

}
